<!--
 * @Description: 
 * @Version: 1.0
 * @Autor: younghxp
 * @Date: 2020-08-21 21:25:47
 * @LastEditors: younghxp
 * @LastEditTime: 2021-12-21 09:12:11
-->
<template>
  <div class="container">
    <topTitle
      :titleText="titleText"
      :back="back"
      @gobackTriser="goBack"
    ></topTitle>
    <div class="mainCon">
      <el-form
        :model="formData"
        :rules="formRules"
        ref="formData"
        label-width="164px"
        class="demo-formData"
      >
        <el-row :gutter="100">
          <el-col :span="12">
            <el-form-item
              prop="projectName"
              label="项目名称："
              class="row-padding-bottom projectName"
            >
              <el-input
                v-model="formData.projectName"
                placeholder="请输入项目名称"
                clearable
                @input="changeProjectName"
                class="proInputWidth"
              ></el-input>
              <div v-if="projectNameFlag" class="commonStyle">
                <template v-for="(item, index) in likeProjects">
                  <p
                    :key="index"
                    @click="clickShowCompany(index)"
                    ref="projectName"
                  >
                    {{ item.projectName || '--' }}
                  </p>
                </template>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row
          :gutter="100"
          v-if="formData.projectName && !formData.projectId"
        >
          <el-col :span="12">
            <el-form-item
              label="施工方名称："
              prop="pbName"
              class="row-padding-bottom"
            >
              <el-input
                type="text"
                placeholder="请输入施工方名称"
                v-model="formData.pbName"
                :disabled="
                  !formData.projectName ||
                  (!!formData.projectName && !!formData.projectId)
                "
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              label="施工方信用代码："
              prop="pbUscc"
              class="row-padding-bottom"
            >
              <el-input
                type="text"
                v-model="formData.pbUscc"
                :disabled="
                  !formData.projectName ||
                  (!!formData.projectName && !!formData.projectId)
                "
                placeholder="请输入施工方统一社会信用代码"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="100" v-else>
          <el-col :span="12">
            <el-form-item label="施工方名称：" class="row-padding-bottom">
              <el-input
                type="text"
                placeholder="请输入施工方名称"
                v-model="formData.pbName"
                :disabled="
                  !formData.projectName ||
                  (!!formData.projectName && !!formData.projectId)
                "
              ></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="施工方信用代码：" class="row-padding-bottom">
              <el-input
                type="text"
                v-model="formData.pbUscc"
                :disabled="
                  !formData.projectName ||
                  (!!formData.projectName && !!formData.projectId)
                "
                placeholder="请输入施工方统一社会信用代码"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="100">
          <el-col :span="12">
            <el-form-item
              prop="industryId"
              label="行业："
              class="row-padding-bottom"
            >
              <el-select
                v-model="formData.industryId"
                filterable
                placeholder="请选择"
                clearable
                class="proInputWidth"
              >
                <el-option
                  v-for="item in industryOptions"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              prop="responsibilityType"
              label="责任主体类型："
              class="row-padding-bottom"
            >
              <el-select
                class="selectWidth"
                v-model="formData.responsibilityType"
                @change="changeResponsibilityType"
                filterable
                placeholder="请选择责任主体类型"
                clearable
              >
                <el-option
                  v-for="item in companyOptions"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                ></el-option
              ></el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="100">
          <el-col :span="12">
            <el-form-item
              prop="companyName"
              :label="
                formData.responsibilityType === 'COMPANY'
                  ? '责任主体企业名称：'
                  : '责任主体姓名：'
              "
              class="row-padding-bottom"
            >
              <el-input
                type="text"
                :placeholder="`请输入${
                  formData.responsibilityType === 'COMPANY'
                    ? '责任主体企业名称'
                    : '责任主体姓名'
                }`"
                v-model="formData.companyName"
                @focus="changeCompanyName"
                maxlength="100"
              ></el-input>
              <template
                v-if="
                  formData.responsibilityType === 'COMPANY' &&
                  isCheckCompanyName
                "
              >
                <ul class="commonStyle">
                  <template v-for="item in projectCompanys">
                    <li @click="checkCompany(item)" :key="item.id">
                      {{ item.companyName || '--' }}
                    </li>
                  </template>
                </ul>
              </template>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              prop="uscc"
              :label="
                formData.responsibilityType === 'COMPANY'
                  ? '责任主体信用代码：'
                  : '责任主体身份证号码'
              "
              class="row-padding-bottom"
            >
              <el-input
                type="text"
                :placeholder="`请输入${
                  formData.responsibilityType === 'COMPANY'
                    ? '责任主体信用代码'
                    : '责任主体身份证号码'
                }`"
                v-model="formData.uscc"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="100">
          <el-col :span="12">
            <el-form-item
              prop="areaId"
              label="事项发生地区："
              class="row-padding-bottom"
            >
              <el-cascader
                class="selectWidth"
                v-model="areaId"
                :options="areasOptions"
                ref="myAreaCascader"
                @change="getAreaId"
                clearable
                filterable
                placeholder="请选择"
              ></el-cascader>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              prop="disputeDate"
              label="事项时间："
              class="row-padding-bottom"
            >
              <el-date-picker
                v-model="formData.disputeDate"
                type="date"
                placeholder="选择日期"
                :picker-options="pickerOptions"
                value-format="yyyy-MM-dd"
                clearable
                :style="{ width: '100%' }"
              ></el-date-picker>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="100">
          <el-col :span="12">
            <el-form-item label="事项类别：" class="row-padding-bottom">
              <el-select
                class="selectWidth"
                @change="changeAccidentType"
                v-model="formData.preciseTypeId"
                filterable
                placeholder="请选择"
                clearable
              >
                <el-option
                  v-for="item in accidentTypeList"
                  :key="item.code"
                  :label="item.name"
                  :value="item.code"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否约谈：">
              <el-radio-group v-model="formData.isInterviewed">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="100">
          <el-col :span="12">
            <el-form-item label="是否处理：">
              <el-radio-group v-model="formData.isHandled">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否下达整改文书：" prop="isCorrected">
              <el-radio-group v-model="formData.isCorrected">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="100">
          <el-col :span="12">
            <el-form-item label="是否欠薪：">
              <el-radio-group v-model="formData.isBackPay">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
              <template v-if="formData.isBackPay">
                <el-row>
                  <el-col :span="12">
                    <el-form-item
                      prop="peopleTotal"
                      class="labelStar fl"
                      label-width="40px"
                      style="margin-bottom: 0px !important"
                    >
                      <span class="star">*</span
                      ><el-input
                        type="text"
                        placeholder="涉及人数"
                        v-model="formData.peopleTotal"
                        style="display: inline-block"
                        class=""
                      ></el-input
                      >&nbsp;人
                    </el-form-item>
                  </el-col>
                  <el-col :span="12">
                    <el-form-item
                      prop="balance"
                      class="labelStar fl"
                      label-width="40px"
                      style="margin-bottom: 0px !important"
                    >
                      <span class="star">*</span
                      ><el-input
                        type="text"
                        placeholder="涉及金额"
                        v-model="formData.balance"
                        style="display: inline-block"
                        class=""
                      ></el-input
                      >&nbsp;元
                    </el-form-item>
                  </el-col>
                </el-row>
              </template>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="是否立案：" prop="isRegistered">
              <el-radio-group v-model="formData.isRegistered">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="100">
          <el-col :span="12">
            <el-form-item label="是否移交公安：">
              <el-radio-group v-model="formData.isTransfered">
                <el-radio :label="1">是</el-radio>
                <el-radio :label="0">否</el-radio>
              </el-radio-group>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item
              prop="disputeRank"
              label="事项程度："
              class="row-padding-bottom"
            >
              <el-select
                class="selectWidth"
                v-model="formData.disputeRank"
                filterable
                placeholder="请选择"
                clearable
              >
                <el-option
                  v-for="item in disputeRank"
                  :key="item.id"
                  :label="item.name"
                  :value="item.id"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row :gutter="100">
          <el-col :span="12">
            <el-form-item label="案号：">
              <el-input
                type="text"
                placeholder="请输入案号"
                v-model="formData.reference"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item
              label="事项情况："
              prop="illustration"
              class="row-padding-bottom"
            >
              <el-input
                type="textarea"
                :rows="5"
                v-model="formData.illustration"
                id="homeAddress"
                placeholder="请输入事项原因,格式内容为既yyyy 年mm月dd日 某企业参建的某项目发生了某事项原因，200字符以内"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="处理结果：" class="row-padding-bottom">
              <el-input
                type="textarea"
                :rows="5"
                maxlength="500"
                v-model="formData.result"
                id="homeAddress"
                placeholder="请输入处理结果，500字符以内"
              ></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row class="row-padding-bottom">
          <el-col :span="24" class="col-position">
            <el-form-item label="上传事项资料" prop="content" class="content">
              <uploadAnnex
                @getFileList="getFileList"
                :limitationFactor="limitationFactor"
                @getFile="getFile"
                :upLoadFile="upLoadFile"
              />
              <!-- <ul class="upLoadFile">
                <li v-for="(item,index) of upLoadFile" :key="index">
                  <i class="icon iconfont iconfujian"></i>
                  {{item.name}}
                  <span class="del" @click="delFile(index)">删除</span>
                </li>
              </ul> -->
            </el-form-item>
            <el-row>
              <el-col :span="24">
                <uploadResult
                  :resultList="upLoadFile"
                  @callBackResult="getFile"
                />
              </el-col>
            </el-row>
          </el-col>
        </el-row>
        <div class="submitBox">
          <el-button
            type="primary"
            class="commonBut saveBtn"
            :loading="isSaveLoading"
            @click.native="saveForm"
            >保存</el-button
          >
          <el-button class="commonBut" @click="goBack">取消</el-button>
        </div>
      </el-form>
    </div>
  </div>
</template>
<script>
import common from '../../kits/common'

import { mapActions, mapState } from 'vuex'
export default {
  name: 'addSuperviseItem',

  data() {
    var checkArea = (rule, value, callback) => {
      var that = this
      if (!that.formData.areaId) {
        return callback(new Error('发生地区不能为空'))
      } else {
        callback()
      }
    }
    //验证项目名称
    var validateProjectName = (rule, value, callback) => {
      value = value.replace(/\s+/g, '')
      if (value === '') {
        callback(new Error('项目名称不能为空'))
      }
      // 项目名称：支持手动输入，必填项。
      // else if(!this.formData.projectId){
      //     callback(new Error("请选择展示的项目名称"));
      // }
      else {
        callback()
      }
    }
    /**
     * @description: 验证涉及金额
     * @param {*}
     * @return {*}
     */

    var checkTotal = (rule, value, callback) => {
      var reg = /^(([1-9]\d*)(\.\d{1,2})?|0\.([1-9]|\d[1-9])|0)$/
      if (!reg.test(value)) {
        return callback(new Error('请输入整数或两位小数'))
      } else if (value > 10000000000) {
        return callback(new Error('涉及金额不可超过100亿'))
      } else if (value <= 0) {
        return callback(new Error('涉及金额应大于0'))
      } else {
        return callback()
      }
    }
    /**
     * @description: 验证涉及人数
     * @param {*}
     * @return {*}
     */
    var checkNum = (rule, value, callback) => {
      var reg = /^(([1-9]\d*)?|0)$/
      if (!reg.test(value)) {
        return callback(new Error('请输入正整数'))
      } else if (value <= 0) {
        return callback(new Error('涉及人数应大于0'))
      } else {
        return callback()
      }
    }
    /**
     * @description: 验证Uscc
     * @param {*}
     * @return {*}
     */
    var checkUscc = (rule, value, callback) => {
      var value = value.replace(/\s+/g, '')
      var regUscc = /^[0-9A-Z]{2}[0-9]{6}[0-9A-Z]{10}$/
      if (this.formData.responsibilityType === 'COMPANY') {
        if (value === '') {
          return callback(new Error('责任主体统一社会信用代码不能为空'))
        } else if (!regUscc.test(value)) {
          return callback(new Error('责任主体统一社会信用代码格式不正确'))
        } else {
          return callback()
        }
      } else {
        var regUsccId =
          /^(([1-9][0-9]{5}(19|20)[0-9]{2}((0[1-9])|(1[0-2]))([0-2][1-9]|10|20|30|31)[0-9]{3}([0-9]|X|x))|([1-9][0-9]{5}[0-9]{2}((0[1-9])|(1[0-2]))([0-2][1-9]|10|20|30|31)[0-9]{3}))$/
        if (value === '') {
          return callback(new Error('责任主体身份证号码不能为空'))
        } else if (!regUsccId.test(value)) {
          return callback(new Error('责任主体身份证号码格式不正确'))
        } else {
          return callback()
        }
      }
    }
    /**
     * @description: 验证施工方Uscc
     * @param {*}
     * @return {*}
     */
    var checkPbUscc = (rule, value, callback) => {
      var value = value.replace(/\s+/g, '')
      var regUscc = /^[0-9A-Z]{2}[0-9]{6}[0-9A-Z]{10}$/
      if (value === '') {
        return callback(new Error('责任主体统一社会信用代码不能为空'))
      } else if (!regUscc.test(value)) {
        return callback(new Error('责任主体统一社会信用代码格式不正确'))
      } else {
        return callback()
      }
    }
    return {
      limitationFactor: {
        uploadAnnexUrl: 'api-f/files/upload', //自定义上传文件接口地址
        upLoadFileLength: 10, //自定义上传文件最大数量设置
        fileSize: 10, //自定义上传文件最大设置
        messageFileSizetip: '最多能上传10M以内的文件', //自定义id解决一个页面包含多个上传附件
        messagetip: '仅支持上传doc、docx、pdf格式文件', //自定义报错提示语
        formatType: 'typeTwo', //自定义上传格式校验类型
        fileId: 'uploadFileInput', //自定义id解决一个页面包含多个上传附件
        uploadFormId: 'uploadFileForm', //自定义id解决一个页面包含多个上传附件
        methodTip: '附件为文档或pdf文件', //自定义上传文件提示
        uploadBtnType: 'typeOne', //自定义上传按钮类型
      },
      //时期选择器
      pickerOptions: {
        disabledDate(time) {
          return time.getTime() >= Date.now()
        },
      },
      titleText: '新增违法记载',
      back: true,
      projectCompanys: [],
      likeProjects: [],
      selectProject: [],
      disputeRank: [], //事项程度
      accidentTypeList: [], //事项类别
      defaultMsg: '',
      upLoadFile: [],
      projectNameFlag: false,
      mainBodyFlag: false,
      oldSrcList: [],
      dialogImageUrl: '',
      srcList: [],
      areaId: '',
      isSaveLoading: false, // 保存loading
      companyOptions: [
        //责任主体类型
        {
          name: '单位',
          code: 'COMPANY',
        },
        {
          name: '个人',
          code: 'PERSONAGE',
        },
      ],
      formData: {
        projectName: '', //--项目名称
        projectId: '', //--项目ID
        pbName: '', //施工方
        pbUscc: '',
        industryId: '', //--行业ID
        uscc: '', //--企业USCC
        companyName: '', //--企业名字
        responsibilityType: 'COMPANY', //责任主体类型
        areaId: '', //--纠纷区域编码（非项目区域编码）
        address: '', //--纠纷发生地点
        disputeDate: '', //--纠纷发生日期
        preciseTypeId: '', //事项类别
        preciseTypeName: '', //事项类别名称
        isInterviewed: '', //--是否约谈（0-否，1-是）
        isHandled: '', //--是否处理（0-否，1-是）
        isCorrected: '', //--是否责令整改（0-否，1-是）
        isBackPay: 0, //--是否欠薪（0-否，1-是）
        balance: '', //涉及金额
        peopleTotal: '', //涉及人数
        isRegistered: '', //--是否立案（0-否，1-是）
        isTransfered: '', //--是否移交公安（0-否，1-是）
        disputeRank: '', //--纠纷级别（枚举：01-一般，05-严重，10-重大）
        isPunished: '', //--是否处罚（0-否，1-是）
        isEnforced: '', //--是否强制执行（0-否，1-是）
        illustration: '', //--纠纷说明
        result: '', //处理结果
        fileList: [],
        reference: '', //案件号
      },
      isCheckCompanyName: false, //是否选择责任主体
      formRules: {
        // projectName: [
        //   { required: true, message: "项目名称不能为空", trigger: "change" }
        // ],
        projectName: [
          { required: true, validator: validateProjectName, trigger: 'blur' },
        ],
        areaId: [{ required: true, validator: checkArea, trigger: 'change' }],
        uscc: [{ required: true, validator: checkUscc, trigger: 'blur' }],
        companyName: [
          {
            required: true,
            message: '责任主体名称不可为空',
            trigger: 'change',
          },
        ],
        industryId: [
          { required: true, message: '行业不能为空', trigger: 'change' },
        ],
        disputeDate: [
          {
            required: true,
            message: '事项发生日期不能为空',
            trigger: 'change',
          },
        ],
        disputeRank: [
          { required: true, message: '事项程度不能为空', trigger: 'change' },
        ],
        disputeType: [
          { required: true, message: '事项类别不能为空', trigger: 'change' },
        ],
        illustration: [
          { required: true, message: '事项情况不能为空', trigger: 'change' },
          { min: 1, max: 200, message: '事项情况不超过200字', trigger: 'blur' },
        ],
        balance: [{ required: true, validator: checkTotal, trigger: 'blur' }],
        peopleTotal: [
          { required: true, message: '请输入涉及人数', trigger: 'blur' },
          { required: true, validator: checkNum, trigger: 'blur' },
        ],
        isCorrected: [
          {
            required: true,
            message: '请选择是否下达整改文书',
            trigger: 'change',
          },
        ],
        isRegistered: [
          { required: true, message: '请选择是否立案', trigger: 'change' },
        ],
        pbName: [
          { required: true, message: '施工方名称不可为空', trigger: 'blur' },
        ],
        pbUscc: [{ required: true, validator: checkPbUscc, trigger: 'blur' }],
      },
      projectCompany: '', //当前选中
    }
  },
  computed: { ...mapState(['areasOptions', 'industryOptions']) },
  watch: {
    'formData.projectId': {
      handler(newVal, oldVal) {
        if (newVal) {
          this.$refs.formData.clearValidate('projectName')
        }
      },
    },
  },
  created() {
    // this.isQy = localStorage.getItem("loginType") == "QY" ? true : false;
    this.getRank() //事项程度
    this.getAreas({ areaId: this.$store.state.areaInfoArr.areaId })
    this.getIndustry({})
    // this.isAddType&&this.getType();//事项类别
    // this.getAreaData();
    // this.getSelecData("INDUSTRY");//涉案人数区间
    this.getSelecData('DISPUTE_TYPE') //事项类别
    //涉及人员INVOLVED_RANGE_NAME
    // this.getIndustry();
  },
  activated() {},
  methods: {
    ...mapActions(['getAreas', 'getIndustry']),
    /**
     * @description: 获取上传的附件
     */
    getFileList(val) {
      this.oldSrcList.push(val)
      this.srcList.push(val)
    },
    /**
     * @description: 获取上传的附件
     */
    getFile(val) {
      this.upLoadFile = val
    },
    changeAccidentType(val) {
      let findOne = this.accidentTypeList.find((v) => v.code === val)
      if (findOne) {
        this.formData.preciseTypeName = findOne.name
        if (findOne.name == '拖欠劳动报酬') {
          this.formData.isBackPay = 1
        }
      } else {
        this.formData.preciseTypeName = ''
      }
    },
    saveForm() {
      var files = []
      this.upLoadFile.forEach((item) => {
        var pathStr = item.path || ''
        var newName = '',
          fileType = ''
        if (pathStr != '') {
          newName = pathStr.substr(
            pathStr.lastIndexOf('/') + 1,
            pathStr.length - 1
          )
          fileType = pathStr.substr(
            pathStr.lastIndexOf('.') + 1,
            pathStr.length - 1
          )
        }
        files.push({
          id: item.id,
          originalName: item.name,
          size: item.size,
          newName: newName,
          relativePath: item.path,
          name: item.name,
          url: item.path,
          assicuateName: 'T_CS_RIGHTSACCIDENT',
          assicuateId: '-1',
          fileType: fileType,
          isImg: item.isImg,
          contentType: item.contentType,
          path: item.path,
          source: item.source,
          createTime: item.createTime,
        })
      })
      this.formData.fileList = JSON.stringify(files)
      this.formData.address = this.$refs['myAreaCascader'].inputValue

      //return ;
      this.$refs.formData.validate((valid) => {
        if (valid) {
          this.saveFormInfo()
        } else {
          return false
        }
      })
    },
    saveFormInfo() {
      this.isSaveLoading = true
      this.axios({
        method: 'post',
        url: 'api-r/rightsdispute/expand/add',
        data: this.formData,
      })
        .then((response) => {
          this.isSaveLoading = false
          if (!response.data.hasError) {
            this.$message({
              type: 'success',
              message: '保存成功',
            })
            this.formVisible = false
            this.$router.push('/home/events/superviseEvent')
            this.$store.commit('CHANGE_SLIDER_NAME', {
              oldUrl: '/home/events/superviseEvent',
              newUrl: this.$router.currentRoute.fullPath,
            })
          } else {
            this.$message({
              type: 'error',
              message: response.data.errorMsg,
            })
            this.isSaveLoading = false
          }
        })
        .catch((error) => {
          this.$message.error('数据获取失败')
          //this.$message.error("保存失败");
          this.isSaveLoading = false
        })
    },
    getSelecData(type) {
      var url = 'api-bs/base/dicitem/findbytype'
      this.axios({
        method: 'post',
        url: url,
        data: { type: type },
      })
        .then((res) => {
          if (type == 'DISPUTE_TYPE') {
            let arr1 = res.data.result.filter(
              (item) => item.name == '拖欠劳动报酬'
            )
            let arr2 = res.data.result.filter(
              (item) => item.name !== '拖欠劳动报酬'
            )
            this.accidentTypeList = arr1.concat(arr2)
          }
        })
        .catch((error) => {
          this.$message({
            showClose: true,
            duration: 3000,
            message: '获取数据失败',
            type: 'error',
          })
        })
    },
    getRank() {
      this.axios({
        method: 'post',
        url: 'api-r/rightsdispute/expand/getRank',
        data: {},
      })
        .then((response) => {
          this.disputeRank = response.data.result
        })
        .catch((error) => {
          this.$message({
            showClose: true,
            duration: 3000,
            message: '获取事项程度数据失败',
            type: 'error',
          })
        })
    },
    //行业
    getIndustryId() {
      this.formData.industryId =
        this.formData.industryId[this.formData.industryId.length - 1]
    },
    //获取选中的区域最后一级id
    getAreaId() {
      var areaId = this.areaId[this.areaId.length - 1]
      this.formData.areaId = areaId
    },

    goBack() {
      this.$refs['formData'].resetFields()
      this.$router.push('/home/events/superviseEvent')
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl: '/home/events/superviseEvent',
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
    changeProjectName() {
      this.likeProjects = []
      this.formData.uscc = ''
      this.formData.companyName = ''
      this.formData.projectId = ''
      // if (this.formData.projectName.length < 3) {
      //   this.formData.projectId = "";
      //   return;
      // }
      this.axios({
        method: 'post',
        url: 'api-p/project/expand/likeproject',
        data: { projectName: this.formData.projectName },
      }).then((resp) => {
        if (!resp.data.hasError) {
          var listTemps = resp.data.result.results
          if (listTemps.length > 5) {
            for (var i = 0; i < 5; i++) {
              this.likeProjects.push(listTemps[i])
            }
          } else {
            this.likeProjects = listTemps
          }

          if (this.likeProjects.length > 0) {
            this.projectNameFlag = true
          }
        }
      })
    },
    /**
     * @description: 修改责任主体类型
     * @param {*} val
     * @return {*}
     */
    changeResponsibilityType(val) {
      this.formData.companyName = ''
      this.formData.uscc = ''
      if (val === 'COMPANY') {
        this.isCheckCompanyName = true
      }
    },
    /**
     * @description: 修改责任主体名称
     * @param {*}
     * @return {*}
     */
    changeCompanyName() {
      if (this.formData.responsibilityType === 'COMPANY') {
        this.isCheckCompanyName = true
      }
    },
    /**
     * @description: 选择责任主体
     * @param {*} index
     * @return {*}
     */
    checkCompany(item) {
      this.formData.companyName = item.companyName
      this.formData.uscc = item.uscc
      this.isCheckCompanyName = false
    },
    checkSetCompnyName() {
      //手动去修改已经自动导入的USCC的话，清空主键id
      if (
        this.projectCompany.uscc !== this.formData.uscc &&
        this.formData.uscc !== ''
      ) {
        this.formData.projectCompanyId = ''
      }
      this.axios({
        method: 'post',
        url: 'api-p/projectcompany/expand/findcompanyname',
        data: { uscc: this.formData.uscc },
      })
        .then((resp) => {
          if (!resp.data.hasError) {
            this.formData.companyName = resp.data.result
          }
        })
        .catch((resp) => {
          this.$message.error('数据获取失败')
        })
    },
    clickShowCompany(index) {
      this.selectProject = this.likeProjects[index]
      this.formData.projectId = this.selectProject.id
      this.formData.industryId = this.selectProject.industryId
      this.axios({
        method: 'post',
        url:
          'api-p/projectcompany/expand/findtypebyprojectid?projectId=' +
          this.selectProject.id,
      })
        .then((resp) => {
          if (!resp.data.hasError) {
            this.projectCompanys = resp.data.result
            resp.data.result.forEach((v) => {
              if (v.type === '施工方') {
                this.formData.pbName = v.companyName
                this.formData.pbUscc = v.uscc
              }
            })
            this.isCheckCompanyName = true
          }
        })
        .catch((resp) => {
          this.$message.error('数据获取失败')
        })

      this.formData.projectName = this.selectProject.projectName
      this.projectNameFlag = false
    },

    // 获取子组件上传成功后的值
    getData(data) {
      let pathStr = data.path
      let fileType = pathStr.substr(
        pathStr.lastIndexOf('.'),
        pathStr.length - 1
      )
      if (!/\.(doc|docx|pdf)$/.test(fileType)) {
        this.$message({
          message: '仅支持上传doc、docx、pdf格式文件',
          type: 'error',
        })
        return
      }
      this.upLoadFile.push(data)
    },
    successCallBack() {},
    errorCallBack() {},
  },
}
</script>
<style scoped lang="less">
// 上传附件
.upLoadBox {
  // display: inline-block;
  position: relative;
  .upLoadDom {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    /deep/ #salaryExcelForm {
      line-height: 36px;
    }
    /deep/ #salaryExcel {
      width: 136px;
      height: 36px;
    }
  }
}

.uploadImgState {
  font-size: 14px;
  color: #999999;
  margin-left: 12px;
}
.uploadImg {
  width: 96px;
  height: 36px;
  color: #009588;
  border: 1px solid #009588;
  line-height: 10px;
}

// 上传文件
.upLoadFile {
  color: #333;
  line-height: 21px;
  li {
    margin-bottom: 10px;
    i {
      color: #999;
      margin: 0 5px 0 15px;
    }
    .del {
      font-size: 14px;
      color: #db0202;
      margin-left: 20px;
      cursor: pointer;
    }
  }
}

.upLoadDom:hover {
  cursor: pointer;
}
.topTitle {
  height: 67px;
  background-color: #e4ebf1;
  padding-left: 24px;
  font: bold 18px/67px Microsoft YaHei;
}
.container {
  .mainCon {
    padding: 40px 20px;
    padding-right: 80px;
    /*text-align: center;*/
    .labelStyMin {
      padding-left: 0px !important;
      min-width: 130px;
    }
    .labelStyMax {
      padding-left: 0px !important;
      margin-left: 5px;
      min-width: 155px;
    }
    .submitBox {
      text-align: center;
    }
    .picStyle {
      width: 116px;
      margin-right: 60px;
      img {
        width: 100%;
      }
    }
    .imgStyle {
      padding-left: 130px;
      li {
        position: relative;
        margin-right: 20px;
        margin-top: 10px;
        i {
          position: absolute;
          right: -6px;
          top: -10px;
          font-size: 20px;
        }
      }
    }
    .projectName {
      ul {
        position: relative;
        background: #fff;
        width: 320px;
        min-height: 80px;
        top: 5px;
        left: 0;
        margin-bottom: 12px;
        padding: 12px;
        z-index: 2000;
        color: #606266;
        line-height: 1.4;
        font-size: 14px;
        box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
        word-break: break-all;
        transform-origin: center top;
        border-radius: 4px;
        border: 1px solid #ebeef5;
        li {
          padding: 12px 0;
          &:hover {
            background: #f8f8f8;
            cursor: pointer;
          }
        }
      }
      .el-radio {
        padding: 8px 0;
      }
    }
  }
}
form.el-form.demo-formData {
  width: 100%;
  display: inline-block;
  text-align: left;
  .infoTitle {
    font-size: 16px;
    padding: 16px 24px;
    background: #f5f7fb;
    margin-bottom: 24px;
    color: #333;
    font-weight: 700;
  }
  .selectWidth {
    width: 100%;
  }
  .proInputWidth {
    width: 100%;
  }
}
.el-main .el-form-item {
  margin-bottom: 20px;
}
.saveBtn {
  background-color: #009588;
  border-color: #009588;
  color: #fff;
}
.labelStar {
  position: relative;

  .el-input {
    width: calc(100% - 20px);
  }
  .star {
    color: #f56c6c;
    position: absolute;
    top: 0;
    left: -15px;
  }
}
</style>
